{% extends 'base/base.html' %}

{% block title %}
       首页
{% endblock %}

{% block main %}
{% csrf_token %}
    <ul class="list-group">
        {% for article in object_list %}
        <li class="list-group-item">
            <a href="{% url 'main:article_detail' article.id %}">{{ article.title }}</a>

        </li>
        {% endfor %}

    </ul>
  <nav aria-label="Page navigation">
    <ul class="pagination">
        {% if page_obj.has_previous %}
            <li>
                <a href="?page={{ page_obj.previous_page_number }}&category={{ category }}" aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>
        {% else %}
            <li class="disabled">
                <a href="#" aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>
        {% endif %}

        {% for pn in page_obj.paginator.page_range %}
            {% if pn == page_obj.number %}
                <li class="active">
                    <a href="?page={{ pn }}&category={{ category }}">{{ pn }}</a>
                </li>
            {% else %}
                <li>
                    <a href="?page={{ pn }}&category={{ category }}">{{ pn }}</a>
                </li>
            {% endif %}
        {% endfor %}

        {% if page_obj.has_next %}
            <li>
                <a href="?page={{ page_obj.next_page_number }}&category={{ category }}" aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                </a>
            </li>
        {% else %}
            <li class="disabled">
                <a href="#" aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                </a>
            </li>
        {% endif %}
    </ul>
</nav>
{% endblock %}